<?php
require_once ('class.db.php');

$db = new DB();
if(!empty($_POST['mobile'])){
    $data = [
        'username' => $_POST['name'],
        'mobile'   => $_POST['mobile'],
        'money' => '0',
        'time'     => date("Y-m-d H:i:s",time()),
    ];

    try {
        $flag = $db->insert('dk_msg',$data);
    } catch (Exception $e) {
        echo $e->getMessage();
        throw new Exception("Error Processing Request", 1);

    }
}else{
    $flag = 0;
}
if($flag) {
	$msg =['code' => 200,'msg' =>'留言成功'];
	echo json_encode($msg);exit();
}else{
	$msg =['code' => 400,'msg' =>'留言失败'];
	echo json_encode($msg);exit();
}
	
